package com.haizhi.crm.common.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * UI显示方式
 * Created by ch on 2018/2/10.
 */
public enum DisplayType {


    TABLE("表格", "table", "ENTITY" ),
    GRAPH("图", "graph", "GRAPH" ),
    SIMPLE_ATTRIBUTE("简单属性", "simpleAttribute", "ATTR" ),
    NEWS("新闻体", "news", "ATTR" );

    // 成员变量
    private String name;
    private String value;
    private String mapEsSearch;

    private static Map<String, String> mapAttr = new HashMap<>();

    static {
        for (DisplayType item : DisplayType.values()) {
            mapAttr.put(item.getMapEsSearch(), item.getValue());
        }
    }

    // 构造方法
    DisplayType(String name, String value, String mapEsSearch) {
        this.name = name;
        this.value = value;
        this.mapEsSearch = mapEsSearch;
    }

    // 普通方法
    public static String getName(String value) {
        for (DisplayType c : DisplayType.values()) {
            if (c.getValue().equals(value)) {
                return c.name;
            }
        }
        return null;
    }

    public static String getMapValue(String mapEsSearch) {
        return mapAttr.get(mapEsSearch);
    }

    public String getMapEsSearch() {
        return mapEsSearch;
    }

    // get set 方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}
